package cn.david.basic.controller;

import cn.david.basic.exception.BusinessExcepiton;
import cn.david.basic.service.IVerifyCodeService;
import cn.david.basic.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/verifycode")
public class VerifyCodeController {
    @Autowired
    private IVerifyCodeService sendSmsCode;
    @RequestMapping("/sendSmsCode")
    public AjaxResult sendSmsCode(@RequestBody Map<String,String> map){
        try {
            sendSmsCode.sendSmsCode(map);
            System.out.println(map);
            return AjaxResult.me();
        } catch (BusinessExcepiton e){
            return AjaxResult.me().setMessage("发送失败！"+e.getMessage());
        }catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.me().setMessage("网络异常！");

        }
    }
}
